package com.example.codegen;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;

@SpringBootApplication
@Slf4j
public class CodegenApplication {

    public static void main(String[] args) throws Exception {
        ConfigurableApplicationContext application = SpringApplication.run(CodegenApplication.class, args);
        Environment env = application.getEnvironment();
        String address = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        log.info("\n" +
                        "------------------------------------------------------------------\n" +
                        "\tApplication [{}] is running! Access URLs:\n" +
                        "\tLocal: \t\t\thttp://localhost:{}\n" +
                        "\tExternal: \t\thttp://{}:{}\n" +
                        "\tSwagger Doc: \thttp://{}:{}/swagger-ui.html\n" +
                        "\tKnife4j Doc: \thttp://{}:{}/doc.html\n" +
                        "------------------------------------------------------------------",
                env.getProperty("spring.application.name"),
                port,
                address, port,
                address, port,
                address, port
        );
    }
}
